package com.glacier.common.core.domain.form;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * date 2023-01-04 21:23
 * 集合包装类
 *
 * @author glacier
 * @version 1.0.0
 */
public class ListWrapper<T> implements Serializable {

    private static final long serialVersionUID = 7039857253209373364L;

    /**
     * 数据
     */
    private List<T> datas;

    public ListWrapper() {
    }

    public ListWrapper(List<T> datas) {
        this.datas = datas;
    }

    public List<T> getDatas() {
        return Optional.of(datas).orElseGet(() -> datas = new ArrayList<>());
    }

    public void setDatas(List<T> datas) {
        this.datas = datas;
    }

    @Override
    public String toString() {
        return "ListWrapper{" +
            "data=" + datas +
            '}';
    }
}
